﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Forum.BLL.Member;
using Forum.Entity.Member;
using System.Text;
using Frame.Lib.Utilities;

namespace Forum.Web.Admin.UForum.Board
{
    /// <summary>
    /// Summary description for GetMember
    /// </summary>
    public class GetMember : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            //context.Response.Write(context.Request.Form["LoginNames"]);

            List<string> loginNames = StrUtil.SplitToStr(context.Request.Form["LoginNames"]);
            MemberBaseBO member = new MemberBaseBO();

            string notExistUsers;
            List<MemberBaseInfo> list = member.GetList(loginNames, out notExistUsers);

            StringBuilder sbMembers = new StringBuilder();
            sbMembers.Append("{Members:[");
            foreach (MemberBaseInfo info in list)
            {
                sbMembers.Append("{ID:'" + info.ID + "',LoginName:'" + info.LoginName + "'},");
            }

            string str1 = sbMembers.ToString().Trim(',') + "],";
            str1 += "NotExistMember:'" + notExistUsers + "'}";

            context.Response.Write(str1);


            //context.Response.Write("Hello World");
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}